package cn.wolfcode.mp.web.controller;


import cn.wolfcode.mp.qo.JsonResult;
import cn.wolfcode.mp.service.IDepartmentService;
import cn.wolfcode.mp.util.RequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("departments")
public class DepartmentController {

    @Autowired
    private IDepartmentService department;

    @GetMapping("/list")
    @RequiredPermission(name = "部门页面",expression = "department:list")
    public JsonResult list(){
        return new JsonResult(department.list());
    }

    @DeleteMapping("/delete")
    @RequiredPermission(name = "部门删除",expression = "department:delete")
    public JsonResult delete(Long id){
        department.removeById(id);
        return new JsonResult();
    }


}
